#include <iostream>
#include <cstring>

using namespace std;

int main() {
	const int MAX = 100;
	const int MINLEN = 256;
	char s[MAX][MINLEN];
	int n, ans = 0, minLen = 256;

	scanf("%d", &n);
	getchar();
	for (int i = 0; i < n; i++) {
		gets(s[i]);
		int len = strlen(s[i]);
		if (len < minLen) minLen = len;
		for (int j = 0; j < len/2; j++) {
			char temp = s[i][j];
			s[i][j] = s[i][len-j-1];
			s[i][len-j-1] = temp;
		}
	}

	for (int i = 0; i < minLen; i++) {
		char c = s[0][i];
		bool same = true;
		for (int j = 1; j < n; j++) {
			if (c != s[j][i]) {
				same = false;
				break;
			}
		}
		if (same) ans++;
		else break;
	}

	if (ans) {
		for (int i = ans-1; i >= 0; i--) {
			printf("%c", s[0][i]);
		}
	} else {
		printf("nai");
	}

	return 0;
}
